
INCLUDE_DIRECTORIES(
  ${STELLARIUM_BUILD_DIR}
  ${STELLARIUM_SOURCE_DIR}
  ${STELLARIUM_SOURCE_DIR}/core
  ${STELLARIUM_SOURCE_DIR}/core/external
  ${STELLARIUM_SOURCE_DIR}/core/modules
  ${STELLARIUM_SOURCE_DIR}/gui
  ${STELLARIUM_SOURCE_DIR}/scripting
  ${CMAKE_BINARY_DIR}
  ${CMAKE_BINARY_DIR}/src
  ${CMAKE_SOURCE_DIR}/src
  ${CMAKE_SOURCE_DIR}/src/gui
  $ENV{CMAKE_INCLUDE_PATH}
  )

LINK_DIRECTORIES(${STELLARIUM_BUILD_DIR}/src)

SET(TestPlugin_SRCS
  TestPlugin.hpp
  TestPlugin.cpp
  )

# Add here all the .ui files
# -- nothing here yet
SET(TestPlugin_UIS
  )
QT4_WRAP_UI(TestPlugin_UIS_H ${TestPlugin_UIS})

# Compile the resource files
#SET(TestPlugin_RES
#${CMAKE_SOURCE_DIR}/TestPlugin.qrc)
#QT4_ADD_RESOURCES(TestPlugin_RES_CXX ${TestPlugin_RES})

# Add here all the files which require moc compilation
# that is, all the headers with SIGNAL/SLOTS/PLUGIN_INTERFACE etc..
SET(TestPlugin_MOC_HDRS
  TestPlugin.hpp
  )

# After this call, TestPlugin_MOC_SRCS = moc_TestPlugin.cxx
QT4_WRAP_CPP(TestPlugin_MOC_SRCS ${TestPlugin_MOC_HDRS})

SET(extLinkerOption ${QT_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES} ${ICONV_LIBRARIES} ${INTL_LIBRARIES})

############### For building the dynamic library ######################
IF(BUILD_DYNAMIC_LIB)
 ADD_LIBRARY(TestPlugin MODULE ${TestPlugin_SRCS} ${TestPlugin_MOC_SRCS} ${TestPlugin_RES_CXX} ${TestPlugin_UIS_H})

 IF(APPLE)
  FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
  MARK_AS_ADVANCED(OPENGL_LIBRARY)
  SET_TARGET_PROPERTIES(TestPlugin PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" SUFFIX ".dylib")
 ENDIF(APPLE)

 IF(WIN32)
  SET_TARGET_PROPERTIES(TestPlugin PROPERTIES LINK_FLAGS "-enable-runtime-pseudo-reloc -Wl,--allow-multiple-definition" )
  SET(StelMain stelMain)
 ELSE(WIN32)
  SET(StelMain )
 ENDIF(WIN32)

 TARGET_LINK_LIBRARIES(TestPlugin ${StelMain} ${extLinkerOption})

 INSTALL(TARGETS TestPlugin DESTINATION "modules/${PACKAGE}")
ENDIF(BUILD_DYNAMIC_LIB)

############### For building the static library ######################
IF(BUILD_STATIC_LIB)
 ADD_LIBRARY(TestPlugin-static STATIC ${TestPlugin_SRCS} ${TestPlugin_MOC_SRCS} ${TestPlugin_RES_CXX} ${TestPlugin_UIS_H})
 SET_TARGET_PROPERTIES(TestPlugin-static PROPERTIES OUTPUT_NAME "TestPlugin")
 TARGET_LINK_LIBRARIES(TestPlugin-static ${StelMain} ${extLinkerOption})
 SET_TARGET_PROPERTIES(TestPlugin-static PROPERTIES COMPILE_FLAGS "-fPIC -DQT_STATICPLUGIN")
ENDIF(BUILD_STATIC_LIB)
